using System;
using System.IO;
using System.Windows.Media;
using Intuipic.Interop;

namespace Intuipic.Data
{
	/// <summary>
	/// Provides a concrete implementation of <see cref="DirectoryInformationBase"/> that represents the Windows desktop.
	/// </summary>
	/// <remarks>
	/// This class implements the singleton pattern to ensure that only one instance of <c>DesktopInformation</c> exists.
	/// </remarks>
	public sealed class DesktopInformation : DirectoryInformationBase
	{
		private static readonly ImageSource _icon = IconHelper.GetSpecialFolderIcon(Environment.SpecialFolder.Desktop);
		private static readonly DesktopInformation _instance = new DesktopInformation();

		/// <summary>
		/// Gets the one and only instance of <see cref="DesktopInformation"/>.
		/// </summary>
		public static DesktopInformation Instance
		{
			get
			{
				return _instance;
			}
		}

		private DesktopInformation()
			: base(_icon, _icon, null, new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)))
		{
		}

		/// <summary>
		/// Loads the children of this desktop informational item.
		/// </summary>
		protected override void LoadChildrenCore()
		{
			//desktop always has My Documents and My Computer
			Children.Add(MyDocumentsInformation.Instance);
			Children.Add(MyComputerInformation.Instance);
			//then it has the directories actually on the desktop
			base.LoadChildrenCore();
		}
	}
}
